extends "../i_TD_mitt_Hide/i_TD_mitt_Hide.gd"

func init():
	.init()
	name = "棱刺手套"
	resetdata()
	info = info + "虚空棱刺：每秒为前方1格敌人附加3层<流血>；被攻击时20%使自身减免30%伤害并使攻击者眩晕1s[cd:3秒]\n" 

func _connect():
	._connect()
	masCha.connect("onHurt",self,"reducedmg")

func reducedmg(atkinfo):
	if atkinfo.isMiss || atkinfo.atkCha == self || !atkinfo.atkCha:return
	if sys.rndPer(20) && !flag:
		flag = 1
		atkinfo.hurtVal *= 0.7
		atkinfo.atkCha.addBuff(ctrl.b_xuanyun.new(0.5))

func _upS():
	._upS()
	if flag:
		cnt2 += 1
		if cnt2 == 3:
			flag = 0
			cnt2 = 0
	var v
	if masCha.aiCha.cell.x > masCha.cell.x:
		v = Vector2(1,0)
	elif masCha.aiCha.cell.x < masCha.cell.x:
		v = Vector2(-1,0)
	elif masCha.aiCha.cell.y > masCha.cell.y:
		v = Vector2(0,1)
	else:
		v = Vector2(0,-1)
	var cell = masCha.cell + v
	if sys.main.isMatin(cell):
		var cha = sys.main.matCha(cell)
		if cha:
			cha.addBuff(b_liuXue.new(3))